import java.util.Scanner;

public class Ex5_31{
	public static void main(String[] args){
		System.out.printf("%b\n", isValid(4388576018410707L));
	}

	public static boolean isValid(long number){
		int s = getSize(number);
		if (s < 13 || s > 16)
			return false;
		long p1 = getPrefix(number, 1);
		long p2 = getPrefix(number, 2);
		if ( p1 != 4 && p1 != 5 && p2 != 37 && p1 != 6)
			return false;
		int se = sumOfDoubleEvenPlace(number);
		int so = sumOfOddPlace(number);
		int sum = se + so;
		if (sum % 10 == 0)
			return true;
		else
			return false;
	}

	public static int sumOfDoubleEvenPlace(long number){
		int s = 0;
		while (number != 0){
			long d = (number % 100) / 10;
			s += getDigit((int)d*2);
			number /= 100;
		}
		return s;
	}

	public static int getDigit(int number){
		int r;
		if (number < 10)
			r = number;
		else
			r = number % 10 + number / 10;
		return r;
	}

	public static int sumOfOddPlace(long number){
		int s = 0;
		while (number != 0){
			long d = (number % 100) % 10;
			s += (int)d;
			number /= 100;
		}
		return s;
	}

	public static boolean prefixMatched(long number, int d){
		while (number >= 10)
			number /= 10;
		return (int)number == d;
	}

	public static int getSize(long number){
		int s = 0;
		while (number != 0){
			number /= 10;
			s++;
		}
		return s;
	}

	public static long getPrefix(long number, int k){
		int s = getSize(number);
		if (k > s)
			return number;
		int w = s - k;
		long n = (long)Math.pow(10, w);
		return number / n;
	}
}
